﻿using NUnit.Framework;

namespace ProjetoComperio.Test.ComperioFramework.Tracking
{
    [TestFixture]
    public class PropertiesTrackingTest
    {
        //public Person entity; //This entity is used to run some tests
        //[SetUp]
        //public void SetUp()
        //{
        //    entity = new Person();
        //}

        //[Test]
        //public void TestRetrivePropertyTrackingKeys()
        //{
        //    Dictionary<String, PropertyTracking> dictionary = PropertiesTracking.RetrievePropertyTracking(entity);
        //    Assert.IsTrue(ExistElementInDictionaryByKey(dictionary, entity));
        //}

        //[Test]
        //public void TestRetrivePropertyTrackingPropertyTrackingValues()
        //{
        //    Boolean resul = true;

        //    Dictionary<String, PropertyTracking> dictionary = PropertiesTracking.RetrievePropertyTracking(entity);
        //    foreach (var item in dictionary.Keys)
        //        resul &= (String.IsNullOrEmpty(dictionary[item].TrackingMessage) && dictionary[item].IsValid);

        //    Assert.IsTrue(resul);
        //}

        //[Test]
        //[ExpectedException(typeof(System.NullReferenceException))]
        //public void TestRetrivePropertyTrackingNullTest()
        //{
        //    Dictionary<String, PropertyTracking> dictionary = PropertiesTracking.RetrievePropertyTracking(null);

        //}

        //[Test]
        //public void TestRetrievePropertyTrackingWithListOfObjects()
        //{

        //    List<Object> lstObjects = new List<object>();
        //    lstObjects.Add(new Person());
        //    lstObjects.Add(new Object());

        //    Dictionary<String, PropertyTracking> dictionary = PropertiesTracking.RetrievePropertyTracking(lstObjects);

        //    Assert.IsTrue(ExistElementInDictionaryByKey(dictionary, entity) && ExistElementInDictionaryByKey(dictionary, new Object()));




        //}

        //private Boolean ExistElementInDictionaryByKey(Dictionary<String, PropertyTracking> dictionary, object obj)
        //{
        //    Boolean resul = true;
        //    foreach (PropertyInfo item in obj.GetType().GetProperties())
        //        resul &= (dictionary[item.Name] != null);
        //    return resul;
        //}


    }
}
